1. Field of the Invention
The present invention relates to a high-speed loop processing (repeated processing) occupying many portions of a substantial practical step of an exclusive or general data processor, in particular to a high-speed processing of an algorithm shown by a while sentence in C or Pascal language, a Do sentence in Fortran language and the like.
2. Description of the Prior Art
One of important control structures in a program of a data processor represented by a general micro processor, digital signal processor (DSP) and the like is a loop processing. A loop is a general idea effective in the case where the same processing is carried out for a large number of data and frequently used in the processing of a text block, array and the like.
For example, in a Centigrade-Fahrenheit temperature correspondence table printing program described in page 10 of the first edition, 1981, of B.W. Carnihan and F. M. Ritchy: "Programming Language C" (Kyoritsu Shuppan), in order to repeatedly carry out a Centigrade conversion-printing processing of a plurality of Fahrenheit temperature data having definite graduations from a lower limit to an upper limit in the temperature table, a loop processing expressed by a while sentence is used, as shown in Table 1.
This program shown in Table 1 means that a processing, in which a value of a lower limit is put in a variable fahr, subsequently a value of celsius=5/9 (fahr-32) being calculated until a value of the variable fahr becomes equal to a value of an upper limit, the value of fahr and value of celsius being indicated using a field of four and six digits, respectively, (in the latter down to one decimal place), a line being changed, and the value of fahr being increased at a graduation equal to a value of a step, is repeated.
TABLE 1 ______________________________________ Prior Art ______________________________________ /*print Centigrade- Fahrenheit temperature*/ /*correspondence table for f = 0, 20, . . . , 300*/ main( ) int lower, upper, step; float fahr, celsius; lower = 0; */lower limit in temperature table*/ upper = 300; */upper limit*/ step = 20; */step*/ fahr = lower; while(fahr&lt; = upper) ( celsius = (5.0/9.0)*(fahr-32.0); printf("%4/0f%6.1f n", fahr, celsius); fahr = fahr + step; ) ) ______________________________________
In a usual program a loop structure expressed by a while sentence or for sentence is generally used side by side with an if-else structure but a substantial processing sequence of the loop processing occupies a rate larger than that occupied by a number of steps in high-level language. Accordingly, in order to high-speed data processor as a whole, the high-speed loop processing portion is indispensable.
In the conventional data processor, in order to carry out this loop processing, a branch instruction, loop instruction, or condition test, decrement and branch instruction have been used. For example, in a 16 bit micro processor 18086 manufactured by Intel, Corp., the loop processing corresponding to a while sentence of said Centigrade-Fahrenheit temperature correspondence table program has been carried out using a branch instruction shown in Table 2.
This Table 2 means that a value of a variable lower is transferred to fahr, a value of fahr being compared with a value of upper, and if both are equal to each other, the value of the variable lower is jumped to a instruction int with a label end marked, otherwise the program itself being executed, a sum of the value of fahr and a value of step being stored in fahr, and the stored sum being returned to a instruction cmp with a label begin marked. In addition, the control is returned to an operating system by executing the instruction int.
TABLE 2 ______________________________________ Prior Art ______________________________________ :/*Centigrade-Fahrenheit temperature : correspondence table printing program : lower = 0; are assumed to be stored in memory : upper = 300, or register and initialized : step = 20 : fahr is assumed to be stored in memory*/ mov fahr, lower begin: cmp fahr upper jb end main portion of Centigrade-Fahrenheit conversion program written by Assembler language (converting and printing value of fahr to Fahrenheit) add fahr, step jmp begin end: int return ;program end interruption ______________________________________
In the conventional data processor including 18086, it is necessary to carry out a processing, in which the addition of a value of current program counter (PC) to a value of address offset, which is an operand of the data processor, is carried out, to calculate the subsequent instruction address after every branch. As to 18086, this fact is described in the description of branch instruction (p. 177 to p. 196) of an iAPX86 macro-assembly language programming manual published by Intel Japan, Ltd, on Feb. 20, 1981. In addition, although it is not shown in Table 2, an algorithm, in which loop instruction, which is another instruction for supporting a loop in 18086, reduces the contents of a CX register "1" by "1" after every passage thereof through the loop and a displacement disp of the loop is added to a instruction pointer IP until a value of the CX resister amounts to "0", as shown by C language in Table 3, is executed and also in the branch by this instruction, it is necessary to obtain the subsequent instruction address. This fact also is described in the above described manual (p. 201 to p. 203).
TABLE 3 ______________________________________ Prior Art ______________________________________ /*algorithm of loop instruction*/ while(CX--==0) { IP=IP+disp; } ______________________________________
Since the loop processing of the conventional data processor machine has been carried out in the above described manner, problems have occurred in that it is necessary to calculate a branch address after every one loop processing and an unnecessary prefetch is carried out over a branch instruction address, as shown in FIG. 1, whereby a wasteful bus cycle is generated to lower a speed of the loop processing.
In addition, these problems are particularly called in question in the last step of a code block forming the loop. Because it is necessary to branch to a loop-beginning address to continue the loop in this step.